<?php


namespace app\admin\controller;


use app\admin\model\ImportLog as ImportLogModel;
use app\admin\model\ImportErrLog as ImportErrLogModel;
use app\common\controller\AdminController;
use think\Exception;

class ImportLog extends AdminController {

    public $levelConfig = [
        1 => ['getlist', 'errinfo'],
        2 => [],
        4 => [],
        8 => []
    ];

    /**
     * 列表
     * @return false|string
     */
    public function getlist() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            $data = ImportLogModel::getList($params);
            return $this->resData('success', $data);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 失败详情
     * @return false|string
     */
    public function errInfo() {
        try {
            $params = $this->checkParams('id,page,long');
            if ($params === false) return $this->resErr();
            $data = ImportErrLogModel::errInfo($params);
            return $this->resData('success', $data);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}